<template>
    <div>
        <a-month-picker placeholder="请选择月份" :value="tempDateValue(formData[dataIndex])" @change="onChange"
            :disabled-date="disabledDate" :allowClear="allowClear">
            <!-- <a-icon slot="suffixIcon" type="smile" /> -->
        </a-month-picker>
    </div>
</template>
<script>
import moment from 'moment';
export default {
    name: 'FormData',
    props: {
        menuId: {
            type: [String, Number],
            default: 2,
        },
        formData: {
            type: Object,
            default: () => { }
        },
        dataIndex: {
            type: String,
            default: 'data',
        },
        onCallBack: {
            type: Function,
            default: () => { }
        },
        allowClear: {
            type: Boolean,
            default: true,
        }
    },
    methods: {
        onChange(date, dataString) {
            this.onCallBack(dataString, this.dataIndex);
        },
        disabledDate(current) {
            return current && moment(current).format('YYYY-MM') > moment().format('YYYY-MM');
        },
        tempDateValue(val) {
            return val ? moment(val, 'YYYY-MM') : null;
        }
    }
}
</script>
<style lang="less" scoped></style>